package servlet;
import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

import model.*;
import db.DB;
public class AddServlet extends HttpServlet{
	public void doGet(HttpServletRequest request,HttpServletResponse response)
	throws ServletException,IOException{
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		String title=request.getParameter("title");
		PrintWriter out = new  PrintWriter(response.getWriter());
//		out.print(title);
		String content=request.getParameter("content");
		User user=(User)request.getSession().getAttribute("user");
		LyTable ly=new LyTable();
		ly.setUserId(user.getId());
		ly.setDate(new Date(System.currentTimeMillis()));
		ly.setTitle(title);
		ly.setContent(content);
		if(new DB().addInfo(ly)){
			response.sendRedirect("success.jsp");
		}
	}
		public void doPost(HttpServletRequest request,HttpServletResponse response)
		throws ServletException,IOException{
			doGet(request,response);
		}
	}
